<?php

namespace app\api\controller\cps;

use app\common\controller\Api;
use think\Request;


/**
 * 美团联盟接口
 */
class Mt extends Api
{
    protected $noNeedLogin = ['queryorder','waimaiorder'];
    protected $noNeedRight = ['*'];


    //查询商品
    public function querycoupon()
    {
        try {
            $page = input('page',1);
            $longitude = input('longitude','');
            $latitude = input('latitude','');
            $listTopiId = input('listTopiId','');
            $sortField = input('sortField','');
            $ascDescOrder = input('ascDescOrder','');
            $platform = input('platform',1);
            $bizLine = input('bizLine',1);
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->queryCoupon($page,$longitude,$latitude,$listTopiId,$sortField,$ascDescOrder,$platform,$bizLine,$this->auth->id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }


    //推广链接
    public function getlink()
    {
        try {
            $linkType = input('linkType',4);
            $skuViewId = input('skuViewId','');
            $platform = input('platform',1);

            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->getlink($linkType,$skuViewId,$platform,$this->auth->id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //订单查询
    public function queryorder()
    {
        try {
            $platform = input('platform',1);
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->queryorder($platform,$this->auth->id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //外卖订单查询
    public function waimaiorder()
    {
        try {
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->waimaiorder();

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('请求成功',$res);
    }

    //美团页分享海报
    public function poster()
    {
        /*$request = Request::instance();
        $domain=$request->domain();
        $url = $domain.'/assets/img/cps/mtwm.png';
        $this->success('请求成功',$url);*/
        try {
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->miniCode($this->auth->id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }

    //美团页复制链接的链接
    public function url()
    {
        //$url = 'https://dpurl.cn/Gdxp1XSz';
        try {
            $linkType = input('linkType',1);
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->url($linkType,$this->auth->id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }

    //推广活动生成二维码
    public function qrcode()
    {
        try {
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->miniCode($this->auth->id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }

    //酒店活动
    public function hotel()
    {
        try {
            $act_id = input('act_id','');
            $jd_model = new \app\api\model\cps\Mt();
            $res = $jd_model->hotel($this->auth->id,$act_id);

        }  catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('',$res);
    }
}